package lib

import "strings"

func init() {
	Probs = append(Probs, Problem{
		Num:         345,
		Discription: "翻转字母串中的元音字母",
		Level:       1,
		Labels: map[string]int{
			"双指针滑动": 1,
		},
	})
}

func ReverseVowels(s string) string {
	n := len(s)
	bytes := []byte(s)
	i := 0
	j := n - 1
	for i < j {
		for  i < j&&!strings.Contains("aeiouAEIOU", string(bytes[i]))  {
			i++
		}
		for  i < j&&!strings.Contains("aeiouAEIOU", string(bytes[j])) {
			j--
		}
		if i != j {
			bytes[i], bytes[j] = bytes[j], bytes[i]
			//和快排不同，换完要++ --
            i++
            j--
		}
	}

	return string(bytes)
}